﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using PerformanceDude.MSBuildShellExtension.Common;

namespace PerformanceDude.MSBuildShellExtension
{
    /// <summary>
    /// Interaction logic for SettingsView.xaml
    /// </summary>
    public partial class SettingsView : Window
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="SettingsView"/> class.
        /// Parameter-less constructor is required for the designer
        /// </summary>
        public SettingsView()
            : this(null)
        {

        }

        public SettingsView(ConfigurationSettings settings)
        {
            //TODO: Low: use custom window icon

            InitializeComponent();

            this.DataContext = settings;
        }

        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                (this.DataContext as ConfigurationSettings).Save();

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
    }
}
